package com.dfbz.dao;

import com.dfbz.entity.Dept;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

import java.util.List;
import java.util.Map;

public class DeptDao extends BaseDao{

    public List<Map<String, Object>> findAll() {
        return jdbcTemplate.queryForList("select dept.*,count(dept.id) deptCount from dept left join user on dept.id = user.dept_id group by dept.id");
    }

    public List<Dept> findDeptAll() {
        return jdbcTemplate.query("select * from dept",new BeanPropertyRowMapper<>(Dept.class));
    }
}
